import React,{Suspense} from 'react'
import RouteList from "./RouteList"
import {RouteLists,RouteItem } from "../utils/Type"
import {BrowserRouter,Route,Routes,Navigate} from "react-router-dom"
type Props = {}

const index = (props: Props) => {

    let renderDom = (routs:RouteLists) => {
        return routs.map((item:RouteItem, index:number) => {
            return <Route path={item.path} key={index}
                element={item.redirect ? <Navigate to={ item.redirect} />:<item.component/>}>
                {/* 2级路由 */}
                {
                    item.children && renderDom(item.children)
                }
            </Route>
        })
    }
  return (
      <Suspense>
          <BrowserRouter>
              <Routes>
                  {
                      renderDom(RouteList)
                  }
              </Routes>
          </BrowserRouter>
      </Suspense>
  )
}

export default index